package com.yqkj.zysoft.upms.controller;


import com.project.easy.common.framework.web.annotation.ApiValidator;
import com.project.easy.common.framework.web.controller.BaseController;
import com.project.easy.common.log.annotation.Logging;
import com.project.easy.common.util.constants.SysModelConstant;
import com.project.easy.common.util.constants.VersionConstant;
import com.project.easy.common.util.dto.OneLongApiContextParam;
import com.project.easy.common.util.dto.R;
import com.project.easy.common.util.dto.TwoApiContextParam;
import com.yqkj.zysoft.upms.entity.dto.AuthTreeResponse;
import com.yqkj.zysoft.upms.entity.dto.FrameWorkAuthAddRequest;
import com.yqkj.zysoft.upms.entity.dto.FrameWorkAuthUpdateRequest;
import com.yqkj.zysoft.upms.entity.dto.PageAuthRequest;
import com.yqkj.zysoft.upms.service.IFrameworkAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 权限
 * </p>
 * @author GreatorMan.cool
 * @since 2022-08-10
 */
@RestController
@RequestMapping("/api/" + VersionConstant.ONE + "/upms/auth")
public class FrameworkAuthController extends BaseController {

    @Autowired
    private IFrameworkAuthService iFrameworkAuthService;
    /**
     * 功能配置
     * @param twoApiContextParam 参数
     * @return 返回数据
     */
    @PostMapping("/udpateFunctionConfig")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> udpateFunctionConfig(@RequestBody TwoApiContextParam twoApiContextParam) {
        return R.success(iFrameworkAuthService.udpateFunctionConfig(twoApiContextParam.getOne(), Long.valueOf(twoApiContextParam.getTwo())));
    }
    /**
     * 获取功能配置
     * @param oneLongApiContextParam 参数
     * @return 返回数据
     */
    @PostMapping("/getfunctionConfig")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<String> getfunctionConfig(@RequestBody OneLongApiContextParam oneLongApiContextParam) {
        return R.success(iFrameworkAuthService.getfunctionConfig(oneLongApiContextParam.getKey()));
    }
    /**
     * 新增
     * @param frameWorkAuthAddRequest 参数
     * @return 返回数据
     */
    @PostMapping("/add")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Long> add(@RequestBody FrameWorkAuthAddRequest frameWorkAuthAddRequest) {
        return R.success(iFrameworkAuthService.add(frameWorkAuthAddRequest));
    }
    /**
     * 修改
     * @param frameWorkAuthUpdateRequest 参数
     * @return 返回数据
     */
    @PostMapping("/udpate")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> udpate(@RequestBody FrameWorkAuthUpdateRequest frameWorkAuthUpdateRequest) {
        return R.success(iFrameworkAuthService.updateObject(frameWorkAuthUpdateRequest));
    }

    /**
     * 数据
     * @param pageAuthRequest 请求参数
     * @return 返回数据
     */
    @PostMapping("/tree")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<List<AuthTreeResponse>> tree(@RequestBody PageAuthRequest pageAuthRequest) {
        return R.success(iFrameworkAuthService.tree(pageAuthRequest));
    }
    /**
     * 验证编码
     * @param frameWorkAuthUpdateRequest 参数
     * @return 返回数据
     */
    @PostMapping("/verifyCode")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> verifyCode(@RequestBody FrameWorkAuthUpdateRequest frameWorkAuthUpdateRequest) {
        return R.success(iFrameworkAuthService.verifyCode(frameWorkAuthUpdateRequest));
    }
    /**
     * 删除
     * @param sysParamDto 参数
     * @return 返回数据
     */
    @PostMapping("/del")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> del(@RequestBody OneLongApiContextParam sysParamDto) {
        return R.success(this.iFrameworkAuthService.del(sysParamDto.getKey()));
    }
    /**
     * 禁用
     * @param oneApiContextParam 参数
     * @return 返回数据
     */
    @PostMapping("/disAble")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> disAble(@RequestBody OneLongApiContextParam oneApiContextParam) {
        return R.success(this.iFrameworkAuthService.disAble(oneApiContextParam.getKey()));
    }
    /**
     * 启用
     * @param oneApiContextParam 参数
     * @return 返回数据
     */
    @PostMapping("/able")
    @Logging(value = SysModelConstant.UPMS)
    @ApiValidator
    public R<Boolean> able(@RequestBody OneLongApiContextParam oneApiContextParam) {
        return R.success(this.iFrameworkAuthService.able(oneApiContextParam.getKey()));
    }
}
